﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

using H2.NET.Business;

namespace H2.NET.Web.Pages
{
    public partial class Attachments : TaskControl
    {
        #region 属性 Public
        private bool IsUsed
        {
            get
            {
                return false;
                //return TaskAPI.Process == "New Raw Material Introducing" && (TaskAPI.Step == "Fill in the request" || TaskAPI.Step == "HSE" || TaskAPI.Step == "Production" || TaskAPI.Step == "RM"
                //                                                     || TaskAPI.Step == "Purchasing" || TaskAPI.Step == "Planning" || TaskAPI.Step == "Technical Check");
            }
        }
        #endregion

        #region 事件 页面加载
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //如果当前部门不需要显示，退出
            if (!IsUsed)
            {
                this.Visible = false;
                return;
            }

            if (!Page.IsPostBack)
            {
                Attachments1.FileClass   = "RAW";
                Attachments1.AllowUpload = TaskAPI.IsAllowSubmit && (TaskAPI.Step == "Fill in the request" || TaskAPI.Step == "Production" || TaskAPI.Step == "RM" || TaskAPI.Step == "Technical BOM");
                Attachments1.AllowDelete = Attachments1.AllowUpload && (TaskAPI.Step == "Fill in the request" || TaskAPI.Step == "Production" || TaskAPI.Step == "RM" || TaskAPI.Step == "Technical BOM");
            }
        }
        #endregion

        #region 方法 InitControls(初始化)
        public void InitControls(mdc_Material mt)
        {
            //如果当前 Tabs 是隐藏的情况，退出
            if (!IsUsed)
            {
                return;
            }
        }
        #endregion

        #region 方法 Save(保存数据库)
        public void Save()
        {
            if (!Attachments1.AllowUpload)
            {
                return;
            }

            (t_Attachment.process == TaskAPI.Process & t_Attachment.username == UserAPI.UserName & t_Attachment.incident == 0).Edit<t_Attachment>(p =>
            {
                p.Incident = TaskAPI.Incident;
            });
        }
        #endregion
    }
}
